package com.example.coffeeseller_2.model.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.example.coffeeseller_2.views.HomeActivity;

/**
 * Created by WH on 2018/9/6.
 * 开机自启动类
 */

public class AutoStartBroadcastReceiver extends BroadcastReceiver {
    static final String action_boot = "android.intent.action.BOOT_COMPLETED";

    @Override
    public void onReceive(Context context, Intent intent) {

        /*if (HomeActivity.getInstance()!=null){
            return;
        }*/
        Log.d("onReceive : ", "intent.getAction() = " + intent.getAction());
        if (intent.getAction().equals(action_boot)) {
            Intent autoIntent = new Intent(context, HomeActivity.class);

            autoIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            context.startActivity(autoIntent);
        }
    }

}
